package com.gxa.dr2.controller;

import com.gxa.dr2.dto.LayDTO;
import com.gxa.dr2.dto.ResultDTO;
import com.gxa.dr2.param.MyParam;
import com.gxa.dr2.pojo.Empl;
import com.gxa.dr2.pojo.Plan;
import com.gxa.dr2.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @program: customer_relation_manage
 * @description:
 **/
@Controller
@RequestMapping("sale")
public class SaleController {

    @Autowired
    private CustomerService customerService;

    /**
     * 查看销售计划
     * @return
     */
    @GetMapping("plan/list/page")
    public  String listPage(){
        return "/sale/plan-list";
    }

    /**
     * 列表数据
     * @return
     */
    @PostMapping("list/data")
    @ResponseBody
    public LayDTO list(MyParam param){
        return customerService.list(param);
    }

    /**
     * 员工的添加接口
     * @return
     */
    @PostMapping("add/do")
    @ResponseBody
    public ResultDTO addDo(Plan plan){
        System.err.println(plan);
        return customerService.add(plan);
    }
    
    /**
     * 客户发展计划添加页面
     * @return
     */
    @GetMapping("add/page")
    public String addPage(){
        return "/sale/plan-add";
    }

    /**
     * 员工编辑页面
     * @return
     */
    @GetMapping("edit/page")
    public String editPage(){
        return "/sale/plan-edit";
    }

    /**
     * 员工的添加接口
     * @return
     */
    @PostMapping("edit/do")
    @ResponseBody
    public ResultDTO editDo(Plan plan){
        return customerService.edit(plan);
    }

    /**
     * 员工的详细信息
     * @return
     */
    @PostMapping("detail/data")
    @ResponseBody
    public ResultDTO detail(Integer planId){
        System.err.println(planId);
        return customerService.detail(planId);
    }

    /**
     * 删除
     * @return
     */
    @PostMapping("delete")
    @ResponseBody
    public ResultDTO delete(Integer planId){
        return customerService.deleteFalse(planId);
    }


    /**
     * 批量删除员工的数据
     * @return
     */
    @PostMapping("deleteAll")
    @ResponseBody
    public ResultDTO deletAll(@RequestParam(name = "ids[]") Integer[] ids){
        return customerService.deleteAll(ids);
    }



}
